<template>
  <div>
    <a-modal v-model:visible="visible" :mask="false" :maskClosable="false" @ok="handleOk" okText="继续" cancelText="取消" @cancel="handleCancel">
      <template #title>
        <div ref="modalTitleRef" style="width: 100%;">提示</div>
      </template>
      <template #modalRender="{ originVNode }">
        <div :style="transformStyle">
          <component :is="originVNode" />
        </div>
      </template>
      <div>存在未下载完成数据，是否继续下载？</div>
    </a-modal>
  </div>
</template>

<script>
import { Draggable } from "@/mixins/DraggableMixin.js"
import { message } from "ant-design-vue"
export default {
  mixins: [Draggable],
  data() {
    return {
      visible: false
    }
  },
  methods: {
    async handleOk() {
      await window.versions.readyDownloading()
      message.success("请在传输中查看下载")
      this.handleCancel()
    },
    handleCancel() {
      this.visible = false
    }
  },
  async created() {
    if (sessionStorage.getItem('isReady')) return
    sessionStorage.setItem('isReady', true)
    const res = await window.versions.readyDownloads()
    if (res) this.visible = true
  },
}
</script>
<style scoped>
div {
  font-size: 16px;
}
</style>